<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .container {
      position: absolute;
      width: 200px;
      height: 400px;
      background-color: pink;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  </style>
</head>

<body>
  <div id="root"></div>
  <script>
    /* 
      1. ref创建响应式数据
      - 处理基础类型数据
      - dell变成proxy({value:'dell'})这样一个响应式引用
      2. reactive创建响应式数据
      - 处理复杂类型数据
    */

    const app = Vue.createApp({
      template: `
      <div class="container" >
        {{nameObj.name}} -- {{age}}
        <button @click="setAge">增加</button>
        <button @click="setName">修改</button>
      </div>
    `,
      setup(props, context) {
        const { ref, reactive } = Vue;
        let age = ref(33)
        function setAge() {
          age.value += 1
        }
        const nameObj = reactive({ name: 'dell' })
        function setName() {
          nameObj.name = 'huawei'
        }
        return {
          name,
          age,
          nameObj,
          setAge,
          setName
        }
      }
    })
    const vm = app.mount('#root');

  </script>
</body>

</html>